﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
//using System.Web.Mail;
//using System.Web.Helpers;

//using MvcReCaptcha;
using KCMS.BusinessLogic.Interfaces;
using StructureMap;
using KCMS.Web.Models;
namespace KCMS.Controllers
{
    public class FeedbackController : Controller
    {
        private IMailService mail = ObjectFactory.GetInstance<IMailService>();
                
        public ActionResult Index()
        {
            return View();
        }

        [HttpGet]
        public ActionResult Show()
        {
            return PartialView();
        }
        [HttpPost]
        public JsonResult Show(FeedbackViewModel model)
        {
            //if (captchaValid)
            //{
               try
                {
                    mail.SendFeedbackMail(model.Title, model.Email, model.Subtitle, model.Body); // отправка сообщения
                   return Json(new { message = "Письмо успешно отправлено!" }, JsonRequestBehavior.AllowGet);
                }
                catch
                {
                    return Json(new { message = "Ошибка при отпрвке почты!Попробуте позже!" }, JsonRequestBehavior.AllowGet);
                }
            //}
            //else {
            //    return Json(new { message = "ReCapha!" }, JsonRequestBehavior.AllowGet);
            //}
      
        }

    }
}
